package Frame.screen;

import FCRendering.*;
import FCRendering.sw.FCRValues;
import Frame.sayoptional.SayOptionalHelper;
import Frame.sayoptional.SayTextAndOption;
import Frame.shopSet.FixTank;
import Function.FCItemForTankHelper;
import Function.FCMutilPlayCache;
import VWorldGameStudio.*;
import VWorldGameStudio.events.*;
import socket.FCRSocketClient;
import socket.FCRSocketServer;
import utils.*;

import java.awt.event.MouseEvent;
import java.util.Random;

import static FCRendering.FCRMaster.*;

//就是在fcrvalue 的interfacenum == 5时的所有监听
public class GameRunningRListener implements IRListener {
    @Override
    public void listen_mouse_click_game(MouseEvent g) {
        int x = g.getX(), y = g.getY();
        if (g.getButton() == 3) {
            FCPlayerInfo fcPlayerInfo = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getShowWhosBagItem());
            // 人物背包
            if (y > (int) (1002 * FCRMaster.fcv.getProportion()) && y < (int) (1080 * FCRMaster.fcv.getProportion()) && FCRMaster.fcv.getCaseSelectNum() < 0) {
                for (int i = 0; i < 10; i++)
                    if (x > (int) ((647 + i * 64) * FCRMaster.fcv.getProportion()) && x < (int) ((697 + i * 64) * FCRMaster.fcv.getProportion())) {
                        //TODO 点了背包这里，没必要继续下去了
                        //右键使用物品
                        FCItem sItem = itemLib.getItemOfID(fcPlayerInfo.getKnapsack()[i]);

                        if (sItem != null) {
                            fcv.setSelectingUseItem(new FixTank(null, fcPlayerInfo, fcPlayerInfo.getKnapsack()[i], i, false));
                            fcv.closeAllShowWindw();
                            fcv.getUseItemAShopFuntion().reBuildWindow();
                            fcv.setOpenUseItem(true);
                        }
                        return;
                    }
            } else if (y > (int) (924 * FCRMaster.fcv.getProportion()) && y < (int) (1002 * FCRMaster.fcv.getProportion())) {
                //坦克背包
                FCTank tank = tankLib.getTankOfID(fcPlayerInfo.getPlayertank1(), fcPlayerInfo.getPlayertankHostId());
                if (tank != null) {
                    for (int i = 0; i < 10; i++)
                        if (x > (int) ((647 + i * 64) * FCRMaster.fcv.getProportion()) && x < (int) ((697 + i * 64) * FCRMaster.fcv.getProportion())) {
                            //TODO 点了背包这里，没必要继续下去了
                            //右键使用物品
                            FCItem sItem = itemLib.getItemOfID(tank.getKnapsack()[i]);
                            System.out.println("dianle " + i + " " + sItem);
                            if (sItem != null) {
                                fcv.setSelectingUseItem(new FixTank(tank, fcPlayerInfo, tank.getKnapsack()[i], i, true));
                                fcv.closeAllShowWindw();
                                fcv.getUseItemAShopFuntion().reBuildWindow();
                                fcv.setOpenUseItem(true);
                            }
                            return;
                        }
                }
            }
        }

        // 游戏时菜单界面
        if (FCUIConfig.getIn().checkUIClick("gameMenu", x, y)) {
            FCRMaster.fcv.setOpenMenu(!FCRMaster.fcv.isOpenMenu());// 打开关闭菜单
            if (FCRMaster.fcv.isOpenMenu()) {
                FCMixUtil.resetTankNameList();
            }
            return;
        }

        if (fcv.getLookIntos().size() > 0) {
            if (FCUIConfig.getIn().checkUIClick("fightSayClickArea", x, y)) {
                int showLen = Math.min(5, fcv.getLookIntos().size());
                for (int i = 0; i < showLen; i++) {
                    fcv.getLookIntos().pollLast();
                }
                return;
            }
        }

        if (fcv.isShowTeamRequest()) {
            if (FCUIConfig.getIn().checkUIClick("TeamRequestReject", x, y)) {
                if (fcv.isSever()) {
                    FCRSocketServer.getIn().repoRequestJoin(false);
                } else if (fcv.isClient()) {
                    FCRSocketClient.getIn().repoRequestJoin(false);
                }
                fcv.setShowTeamRequest(false);
                return;
            } else if (FCUIConfig.getIn().checkUIClick("TeamRequestAccept", x, y)) {
                if (fcv.isSever()) {
                    FCRSocketServer.getIn().repoRequestJoin(true);
                } else if (fcv.isClient()) {
                    FCRSocketClient.getIn().repoRequestJoin(true);
                }
                fcv.setShowTeamRequest(false);
                return;
            }
        }

        if (FCRMaster.fcv.isOpenMenu()) {
            if (FCUIConfig.getIn().checkUIClick("gameMenuPlayer", x, y)) {
                FCRMaster.fcv.setOpenMenuNum(0);// 菜单-人物
                return;
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuTank", x, y)) {
                FCRMaster.fcv.setShowingTankMenuDetail(null);
                FCRMaster.fcv.setOpenMenuNum(1);// 菜单-战车
                return;
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuTankKu", x, y)) {
                FCRMaster.fcv.setOpenMenuNum(2);// 菜单-车库
                return;
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuMap", x, y)) {
                FCRMaster.fcv.setOpenMenuNum(3);// 菜单-地图
                return;
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuTotalInfo", x, y)) {
                FCRMaster.fcv.setOpenMenuNum(4);// 菜单-统计
                return;
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuSetting", x, y)) {
                FCRMaster.fcv.setOpenMenuNum(5);// 菜单-设置
                return;
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuBack", x, y)) {
                FCRMaster.fcv.setOpenMenu(false);// 菜单-返回
                return;
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuTeam", x, y)) {
                FCRMaster.fcv.setOpenMenuNum(7);// 菜单-坦克列表
                return;
            }
            if (FCRMaster.fcv.getOpenMenuNum() == 5) {
                if (FCUIConfig.getIn().checkUIClick("menuSettingExit", x, y)) {
                    System.exit(0);
                    // 设置退出程序
                } else if (FCUIConfig.getIn().checkUIClick("menuSettingBack", x, y)) {
                    FCRMaster.fcv.setOpenMenu(false);
// 设置返回主菜单
                    return;
                } else if (FCUIConfig.getIn().checkUIClick("menuSettingMusic", x, y)) {
// 设置音乐
                    return;
                } else if (FCUIConfig.getIn().checkUIClick("menuSettingKeyReset", x, y)) {
// 设置恢复默认
                    return;
                } else if (FCUIConfig.getIn().checkUIClick("menuSettingSave", x, y)) {
                    // 设置存档
                    if (FCDataSingles.getWriter().writeSaveData(FCRMaster.player1, FCRMaster.gameSave, FCRMaster.gamedate, FCRMaster.tankLib)) {
                        FCRMaster.fcv.getMessage().add(FCRConstants.SYSTEM + FCRConstants.SAVE + FCRConstants.SAVE_SUCCESS);
                    } else {
                        FCRMaster.fcv.getMessage().add(FCRConstants.SYSTEM + FCRConstants.SAVE + FCRConstants.SAVE_FAILURE);
                    }
                    fcv.showMessage();
                    return;
                } else if (FCUIConfig.getIn().checkUIClick("menuSettingRead", x, y)) {
// 设置读档
                    return;
                }
            } else if (FCRMaster.fcv.getOpenMenuNum() == 7) {

            } else if (FCRMaster.fcv.getOpenMenuNum() == 1) {
                FCTank tank = null;
                if (fcv.getTanknameList().size() > 0) {
                    tank = tankLib.getTankOfID(fcv.getTanknameList().get(fcv.getShowTankMenuTankIndex()),
                            fcv.getTankHostList().get(fcv.getShowTankMenuTankIndex()));
                }
                if (FCUIConfig.getIn().checkUIClick("tankMenuDe10SP", x, y)) {
                    if (tank != null) {
                        int newD = tank.getDefense() - 10;
                        newD = Math.max(0, newD);
                        tank.setDefense(newD);
                        tank.reInitShuxing();
                    }
                    return;
                } else if (FCUIConfig.getIn().checkUIClick("tankMenuDe100SP", x, y)) {
                    if (tank != null) {
                        int newD = tank.getDefense() - 100;
                        newD = Math.max(0, newD);
                        tank.setDefense(newD);
                        tank.reInitShuxing();
                    }
                    return;
                }
            }
        }

        if (FCRMaster.fcv.isShopVedingOpen()) {// 打开售货机
            if (y < 802 * FCRMaster.fcv.getProportion() && y > 779 * FCRMaster.fcv.getProportion() && x < 1317 * FCRMaster.fcv.getProportion() && x > 1245 * FCRMaster.fcv.getProportion() && FCRMaster.fcv.getShopVendingSelectNum() == 0) {
                FCRMaster.fcv.setShopVedingOpen(false);// 关闭售货机
                return;
            }
        }
        if (FCRMaster.fcv.isOpenPhonograph()) {// 留声机
            if (x > 860 * FCRMaster.fcv.getProportion() && x < 1100 && FCRMaster.fcv.getPhonographEnterNum() > -1) {
                FCRMaster.sound.setBackgroundMusic(FCRMaster.fcv.getPhonographMusicNum().get(FCRMaster.fcv.getPhonographEnterNum()));
                return;
            }
        }
        if (FCRMaster.fcv.isOpenCase())// 打开箱子
            if (x < 1160.5 * FCRMaster.fcv.getProportion() && x > 1148.5 * FCRMaster.fcv.getProportion() && y > 409.5 * FCRMaster.fcv.getProportion()
                    && y < 422 * FCRMaster.fcv.getProportion()) {
                FCRMaster.fcv.setOpenCase(false);// 关闭箱子
                return;
            }
        if (FCRMaster.fcv.isOpenSay()) {// npc对话
            if (FCUIConfig.getIn().checkUIClick("npcSayAera", x, y)) {
                fcl.clickSay();
                return;
            }

            if (FCRMaster.fcv.getSayNpcSelectMenu().size() > 0) {
                for (int i = 0; i < FCRMaster.fcv.getSayNpcSelectMenu().size(); i++)
                    if (x > 1430 * FCRMaster.fcv.getProportion() && x < 1555 * FCRMaster.fcv.getProportion()
                            && y > (753 + i * 44) * FCRMaster.fcv.getProportion() && y < (793 + i * 44) * FCRMaster.fcv.getProportion()) {
                        //TODO 对话的点击判断
                        SayTextAndOption op = FCRMaster.fcv.getSayNpcSelectMenu().get(i);
                        FCRMaster.fcv.getSayNpcSelectMenu().clear();//这个顺序不要弄反，clickSayOption后可能会产生新的getSayNpcSelectMenu
                        SayOptionalHelper.getIn().clickSayOption(op);
                        return;
                    }
            }
        }

        if (FCRMaster.fcv.isOpenSayShop() && fcv.getCurrentAShopFuntion() != null) {
            //TODO
            int startX = 556;
            int textY = 0;
            //宽是400  425
            for (int i = 0; i < 7; i++) {
                textY = (int) (60 * fcv.getProportion() + 40 * i * fcv.getProportion());
                //左边
                if (fcv.getMouseX() > (int) ((startX) * fcv.getProportion()) && fcv.getMouseX() < (int) ((startX + 400) * fcv.getProportion())) {
                    if (fcv.getMouseY() > (int) (textY - 30 * fcv.getProportion()) && fcv.getMouseY() < (int) (textY + 10 * fcv.getProportion())) {
                        fcv.getCurrentAShopFuntion().clickLeftWindow(i, FCRValues.leftWindowUI[i]);
                        return;
                    }
                }

                if (fcv.getMouseX() > (int) ((startX + 425) * fcv.getProportion()) && fcv.getMouseX() < (int) ((startX + 425 + 400) * fcv.getProportion())) {
                    if (fcv.getMouseY() > (int) (textY - 30 * fcv.getProportion()) && fcv.getMouseY() < (int) (textY + 10 * fcv.getProportion())) {
                        fcv.getCurrentAShopFuntion().clickRightWindow(i, FCRValues.rightWindowUI[i]);
                        return;
                    }
                }
            }
        }
        if (FCRMaster.fcv.isOpenUseItem() || FCRMaster.fcv.isOpenTanCheResult() || FCRMaster.fcv.isOpenMMWVIP()) {
            //TODO
            int startX = 556;
            int textY = 0;
            //宽是400  425
            for (int i = 0; i < 6; i++) {
                textY = (int) (641 * fcv.getProportion() + 47 * i * fcv.getProportion());
                //左边
                if (fcv.getMouseX() > (int) ((startX) * fcv.getProportion()) && fcv.getMouseX() < (int) ((startX + 400) * fcv.getProportion())) {
                    if (fcv.getMouseY() > (int) (textY - 37 * fcv.getProportion()) && fcv.getMouseY() < (int) (textY + 10 * fcv.getProportion())) {
                        if (FCRMaster.fcv.isOpenUseItem()) {
                            fcv.getUseItemAShopFuntion().clickLeftWindow(i, FCRValues.leftWindowUI[i]);
                        } else if (FCRMaster.fcv.isOpenTanCheResult()) {
                            fcv.getTancheResult().clickLeftWindow(i, FCRValues.leftWindowUI[i]);
                        } else if (FCRMaster.fcv.isOpenMMWVIP()) {
                            fcv.getMmWVipBookFuncion().clickLeftWindow(i, FCRValues.leftWindowUI[i]);
                        }
                        return;
                    }
                }

                if (fcv.getMouseX() > (int) ((startX + 425) * fcv.getProportion()) && fcv.getMouseX() < (int) ((startX + 425 + 400) * fcv.getProportion())) {
                    if (fcv.getMouseY() > (int) (textY - 37 * fcv.getProportion()) && fcv.getMouseY() < (int) (textY + 10 * fcv.getProportion())) {
                        if (FCRMaster.fcv.isOpenUseItem()) {
                            fcv.getUseItemAShopFuntion().clickRightWindow(i, FCRValues.rightWindowUI[i]);
                        } else if (FCRMaster.fcv.isOpenTanCheResult()) {
                            fcv.getTancheResult().clickRightWindow(i, FCRValues.rightWindowUI[i]);
                        } else if (FCRMaster.fcv.isOpenMMWVIP()) {
                            fcv.getMmWVipBookFuncion().clickRightWindow(i, FCRValues.rightWindowUI[i]);
                        }
                        return;
                    }
                }
            }
        }

        if (FCRMaster.fcv.isPlotNpc1SayClick()) {
            if (FCUIConfig.getIn().checkUIClick("jumpNpcSay", x, y)) {
                FCRMaster.fcv.setPlotNpc1SayClick(false);
                return;
            }
        }

        // 右键只有乘降功能
        if (g.getButton() == 3 && !FCRMaster.fcv.isShopVedingOpen() && !FCRMaster.fcv.isOpenCase() && !FCRMaster.fcv.isOpenSay() && !FCRMaster.fcv.isOpenPhonograph()
                /*  && !FCRMaster.fcv.isPlotJumpStep1() */ && !FCRMaster.fcv.isOpenUseTankMenu()) {

            FCRMaster.fcv.setTankMenuCoorX(x);
            FCRMaster.fcv.setTankMenuCoorY(y);
            FCRMaster.fcv.setTankMenuMouseEnterX(-1);
            FCRMaster.fcv.setTankMenuMouseEnterY(-1);
            //这里要判断看下当前的位置是点了什么坦克，要是别的玩家的坦克就不能上
            fcv.getCanUpTankTeamMembers().clear();
            fcv.getCanUpTankTeamMemberChNames().clear();
            fcv.getCanUpTankTeamMembers().add(player1.getName());
            fcv.getCanUpTankTeamMemberChNames().add(player1.getChName());
            for (FCRPlayerLink link : FCMutilPlayCache.getTeamMembers()) {
                if (link.curPlayerHostUID.equals(gameSave.HOST_UID)) {
                    fcv.getCanUpTankTeamMembers().add(link.curPlayerName);
                    FCPlayerInfo p = FCMutilPlayCache.findPlayerByName(link.curPlayerHostUID, link.curPlayerName);
                    if (p != null) {
                        fcv.getCanUpTankTeamMemberChNames().add(p.getChName());
                    }
                }
            }
            /**
             * 更新正在开的车的坐标，地图等备份数据
             */
            gameSave.manualUpdateTankSaveIos();
            fcv.setCurSelectTankOnMap(gameSave.getTankUseTankOfMapTankInfo(FCRMaster.mapLib.getMapOfName(FCRMaster.player1.getMapname()).getMapTankHashMap()));
            FCRMaster.fcv.setOpenUseTankMenuChild(false);
            FCRMaster.fcv.setOpenUseTankMenu(true);
            //右键
            return;
        }
        if (FCRMaster.fcv.isShopVedingOpen() && FCRMaster.fcv.getShopVendingTip().indexOf(FCRConstants.SVT_LOTTERY) < 0) {
            if (y > 277 * FCRMaster.fcv.getProportion() && y < 379 * FCRMaster.fcv.getProportion()) {// 1-3物品
                if (x > 604 * FCRMaster.fcv.getProportion() && x < 829 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingSelectNum(1);
                else if (x > 848 * FCRMaster.fcv.getProportion() && x < 1073 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingSelectNum(2);
                else if (x > 1096 * FCRMaster.fcv.getProportion() && x < 1317 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingSelectNum(3);
                else
                    FCRMaster.fcv.setShopVendingSelectNum(0);
            }
            if (y > 401 * FCRMaster.fcv.getProportion() && y < 503 * FCRMaster.fcv.getProportion()) {// 4-6物品
                if (x > 604 * FCRMaster.fcv.getProportion() && x < 829 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingSelectNum(4);
                else if (x > 848 * FCRMaster.fcv.getProportion() && x < 1073 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingSelectNum(5);
                else if (x > 1096 * FCRMaster.fcv.getProportion() && x < 1317 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingSelectNum(6);
                else
                    FCRMaster.fcv.setShopVendingSelectNum(0);
            }
            if (FCRMaster.fcv.getShopVendingSelectNum() - 1 < ((ShopEvent) FCRMaster.fcv.getPlayingEvent()).getItemid().size() && FCRMaster.fcv.getShopVendingSelectNum() > 0) {
                FCRMaster.fcv.setShopLuckDraw(true);
                FCRMaster.fcv.setShopLuckDrawI(new Random().nextInt(16) + 30);
                FCRMaster.fcv.setShopLuckDrawN(120);
                FCRMaster.fcv.setShopLampNum(0);
            } else FCRMaster.fcv.setShopVendingSelectNum(0);
        }
        // 点击乘降
        if (FCRMaster.fcv.isOpenUseTankMenu()) {
            if (x > FCRMaster.fcv.getTankMenuCoorX() + 38 * FCRMaster.fcv.getProportion() && x < FCRMaster.fcv.getTankMenuCoorX() + 166 * FCRMaster.fcv.getProportion()) {
                for (int i = 0; i < fcv.getCanUpTankTeamMembers().size() + 2; i++) {
                    if (y > FCRMaster.fcv.getTankMenuCoorY() + (17 + 43 * i) * FCRMaster.fcv.getProportion()
                            && y < FCRMaster.fcv.getTankMenuCoorY() + (57 + 43 * i) * FCRMaster.fcv.getProportion()) {
                        FCRMaster.sound.setEffectSound(21);
                        FCPlayerInfo p = null;
                        String[] splitT = null;
                        switch (i) {
                            case 0:
                                if (fcv.getCurSelectTankOnMap().size() == 1) {
                                    // 全部上同一俩车
                                    p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getCanUpTankTeamMembers().get(0));
                                    splitT = fcv.getCurSelectTankOnMap().get(0).split(",");
                                    FCRMaster.gameSave.useTankOfPlayerId(p, splitT[0], splitT[1]);

                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                } else if (fcv.getCurSelectTankOnMap().size() > 1) {
                                    int l = Math.min(fcv.getCanUpTankTeamMembers().size(), fcv.getCurSelectTankOnMap().size());
                                    for (int j = 0; j < l; j++) {
                                        splitT = fcv.getCurSelectTankOnMap().get(j).split(",");
                                        p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getCanUpTankTeamMembers().get(j));
                                        FCRMaster.gameSave.useTankOfPlayerId(p, splitT[0], splitT[1]);
                                    }
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                } else {
                                    // 全部下车
                                    for (String name : fcv.getCanUpTankTeamMembers()) {
                                        p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, name);
                                        FCRMaster.gameSave.useTankOfPlayerId(p, p.getPlayertank1(), p.getPlayertankHostId());
                                    }
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                }
                                break;
                            case 1://牵引
                                if (fcv.getCurSelectTankOnMap().size() == 1) {
                                    FCTank fcTank = tankLib.getTankOfID(fcv.getCurSelectTankOnMap().get(0), gameSave.HOST_UID);
                                    if (fcTank != null) {
                                        player1.addPropulsion(fcTank);
                                    }
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                } else if (fcv.getCurSelectTankOnMap().size() > 1) {
                                    FCRMaster.fcv.setClickTankMenu(1);
                                    FCRMaster.fcv.setOpenUseTankMenuChild(true);
                                } else {
                                    //牵引
                                    player1.removePropulsion();
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                }
                                break;
                            case 2://本机队伍单独上车
                                p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getCanUpTankTeamMembers().get(0));
                                if (fcv.getCurSelectTankOnMap().size() == 1) {
                                    splitT = fcv.getCurSelectTankOnMap().get(0).split(",");
                                    FCRMaster.gameSave.useTankOfPlayerId(p, splitT[0], splitT[1]);
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                } else if (fcv.getCurSelectTankOnMap().size() > 1) {
                                    FCRMaster.fcv.setClickTankMenu(2);
                                    FCRMaster.fcv.setOpenUseTankMenuChild(true);
                                } else {
                                    //下车
                                    FCRMaster.gameSave.useTankOfPlayerId(p, p.getPlayertank1(), p.getPlayertankHostId());
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                }
                                break;
                            case 3://本机队伍2单独上车
                                p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getCanUpTankTeamMembers().get(1));
                                if (fcv.getCurSelectTankOnMap().size() == 1) {
                                    splitT = fcv.getCurSelectTankOnMap().get(0).split(",");
                                    FCRMaster.gameSave.useTankOfPlayerId(p, splitT[0], splitT[1]);
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                } else if (fcv.getCurSelectTankOnMap().size() > 1) {
                                    FCRMaster.fcv.setClickTankMenu(3);
                                    FCRMaster.fcv.setOpenUseTankMenuChild(true);
                                } else {
                                    //下车
                                    FCRMaster.gameSave.useTankOfPlayerId(p, p.getPlayertank1(), p.getPlayertankHostId());
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                }
                                break;
                            case 4:
                                p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getCanUpTankTeamMembers().get(2));
                                if (fcv.getCurSelectTankOnMap().size() == 1) {
                                    splitT = fcv.getCurSelectTankOnMap().get(0).split(",");
                                    FCRMaster.gameSave.useTankOfPlayerId(p, splitT[0], splitT[1]);
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                } else if (fcv.getCurSelectTankOnMap().size() > 1) {
                                    FCRMaster.fcv.setClickTankMenu(4);
                                    FCRMaster.fcv.setOpenUseTankMenuChild(true);
                                } else {
                                    //下车
                                    FCRMaster.gameSave.useTankOfPlayerId(p, p.getPlayertank1(), p.getPlayertankHostId());
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                }
                                break;
                            case 5:
                                p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getCanUpTankTeamMembers().get(3));
                                if (fcv.getCurSelectTankOnMap().size() == 1) {
                                    splitT = fcv.getCurSelectTankOnMap().get(0).split(",");
                                    FCRMaster.gameSave.useTankOfPlayerId(p, splitT[0], splitT[1]);
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                } else if (fcv.getCurSelectTankOnMap().size() > 1) {
                                    FCRMaster.fcv.setClickTankMenu(5);
                                    FCRMaster.fcv.setOpenUseTankMenuChild(true);
                                } else {
                                    //下车
                                    FCRMaster.gameSave.useTankOfPlayerId(p, p.getPlayertank1(), p.getPlayertankHostId());
                                    FCRMaster.fcv.setOpenUseTankMenu(false);
                                }
                                break;
                            default:
                                break;
                        }
                        return;
                    }
                }
            }
            int xd = (int) (fcv.getTankMenuCoorX() + 222 * fcv.getProportion());
            if (x > xd && x < xd + 128 * FCRMaster.fcv.getProportion()) {
                for (int i = 0; i < fcv.getCurSelectTankOnMap().size(); i++)
                    if (y > FCRMaster.fcv.getTankMenuCoorY() + (65 + 43 * i) * FCRMaster.fcv.getProportion()
                            && y < FCRMaster.fcv.getTankMenuCoorY() + (105 + 43 * i) * FCRMaster.fcv.getProportion()) {
                        FCRMaster.sound.setEffectSound(21);
                        FCPlayerInfo p = null;
                        String[] splitT = fcv.getCurSelectTankOnMap().get(i).split(",");
                        String tankid = splitT[0];
                        switch (FCRMaster.fcv.getClickTankMenu()) {
                            case 1:
                                FCTank fcTank = tankLib.getTankOfID(tankid, gameSave.HOST_UID);
                                if (fcTank != null) {
                                    if (fcTank.getBeingTow() == 1) {
                                        player1.removePropulsion();
                                    } else {
                                        player1.addPropulsion(fcTank);
                                    }
                                }
                                break;
                            case 2:
                                p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getCanUpTankTeamMembers().get(0));
                                FCRMaster.gameSave.useTankOfPlayerId(p, tankid, splitT[1]);
                                break;
                            case 3:
                                p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getCanUpTankTeamMembers().get(1));
                                FCRMaster.gameSave.useTankOfPlayerId(p, tankid, splitT[1]);
                                break;
                            case 4:
                                p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getCanUpTankTeamMembers().get(2));
                                FCRMaster.gameSave.useTankOfPlayerId(p, tankid, splitT[1]);
                                break;
                            case 5:
                                p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getCanUpTankTeamMembers().get(3));
                                FCRMaster.gameSave.useTankOfPlayerId(p, tankid, splitT[1]);
                                break;
                        }
                        FCRMaster.fcv.setOpenUseTankMenu(false);
                        return;
                    }
            }
        }

        if (fcv.getShowChuanzhenNames().size() > 0) {
            int sX = (int) (835 * fcv.getProportion());
            int sY = (int) ((1080 - fcv.getShowChuanzhenNames().size() * 44) * fcv.getProportion() / 2);
            int y1 = 0;
            for (int i = 0; i < fcv.getShowChuanzhenNames().size(); i++) {
                y1 = (int) ((19 + 44 * i) * fcv.getProportion()) + sY;
                if (x > sX && x < sX + 250 * fcv.getProportion()) {
                    if (y > y1 && y < y1 + 44 * fcv.getProportion()) {
                        fcv.setWillChuangSongMapName(fcv.getShowChuanzhenNames().get(i));
                        //TODO 并且找到地图中的传送动画，打开显示
                        fcv.getShowChuanzhenNames().clear();
                        FCMapAnimation chuanzhenAni = mapAnimationLibrary.getMapAnimationByName(FCMapAnimationConstant.ChuanZhenName);
                        if (chuanzhenAni != null) {
                            chuanzhenAni.setVisiable(1);
                        }
                        return;
                    }
                }
            }
        }
        if (fcv.getShowTankChuanzhenNames().size() > 0) {
            int sX = (int) (835 * fcv.getProportion());
            int sY = (int) ((1080 - fcv.getShowTankChuanzhenNames().size() * 44) * fcv.getProportion() / 2);
            int y1 = 0;
            for (int i = 0; i < fcv.getShowTankChuanzhenNames().size(); i++) {
                y1 = (int) ((19 + 44 * i) * fcv.getProportion()) + sY;
                if (x > sX && x < sX + 250 * fcv.getProportion()) {
                    if (y > y1 && y < y1 + 44 * fcv.getProportion()) {
                        //TODO 并且找到地图中的传送动画，打开显示
                        String mapName = fcv.getShowTankChuanzhenNames().get(i);
                        if (mapName.equals(player1.getMapname())) {
                            fcv.getMessage().add("已经是当前城镇，无法传送！");
                            fcv.showMessage();
                            fcv.getShowTankChuanzhenNames().clear();
                            return;
                        }
                        String jumpEventId = gameSave.getTankChuanZhenMaps().get(mapName);
                        System.out.println("jumpEventId " + jumpEventId);
                        FCEvent event1 = eventLib.getEventOfName(jumpEventId);
                        if (event1 == null && !event1.getType().equals("jump")) {
                            return;
                        }
                        JumpEvent jumpEvent = (JumpEvent) event1;
                        fcv.getShowTankChuanzhenNames().clear();
                        fcv.setPlayingEvent(jumpEvent);
                        sound.setEffectSound(jumpEvent.getMusicnum0());
                        fcv.setJumpactionnum(0);
                        //TODO 通知队友也要转场了
                        if (fcv.isSever()) {
                            FCRSocketServer.getIn().playerJumpEvent(fcv.getPlayingEvent().getName(), jumpEvent.getDestination());
                        } else if (fcv.isClient()) {
                            FCRSocketClient.getIn().playerJumpEvent(fcv.getPlayingEvent().getName(), jumpEvent.getDestination());
                        }
                        return;
                    }
                }
            }
        }
    }


    @Override
    public void listen_mouse_move_game(MouseEvent g) {
        int ti = FCRMaster.fcv.getFrames();
        int x = g.getX(), y = g.getY();

        if (fcv.isShowTeamRequest()) {
            if (FCUIConfig.getIn().checkUIClick("TeamRequestReject", x, y)) {
                FCRMaster.fcv.setEnterBu(FCUIConfig.getIn().getEnterBuByKey("TeamRequestReject"));
            } else if (FCUIConfig.getIn().checkUIClick("TeamRequestAccept", x, y)) {
                FCRMaster.fcv.setEnterBu(FCUIConfig.getIn().getEnterBuByKey("TeamRequestAccept"));
            } else {
                FCRMaster.fcv.setEnterBu(500);
            }
        }

        if (FCRMaster.fcv.isOpenMenu()) {
            if (FCUIConfig.getIn().checkUIClick("gameMenuPlayer", x, y)) {
                FCRMaster.fcv.setEnterBu(501);// 菜单-人物
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuTank", x, y)) {
                FCRMaster.fcv.setEnterBu(502);// 菜单-战车
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuTankKu", x, y)) {
                FCRMaster.fcv.setEnterBu(503);// 菜单-车库
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuMap", x, y)) {
                FCRMaster.fcv.setEnterBu(504);// 菜单-地图
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuTotalInfo", x, y)) {
                FCRMaster.fcv.setEnterBu(505);// 菜单-统计
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuSetting", x, y)) {
                FCRMaster.fcv.setEnterBu(506);// 菜单-设置
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuBack", x, y)) {
                FCRMaster.fcv.setEnterBu(507);// 菜单-返回
            } else if (FCUIConfig.getIn().checkUIClick("gameMenuTeam", x, y)) {
                FCRMaster.fcv.setEnterBu(508);// 菜单-组队
            } else {
                FCRMaster.fcv.setEnterBu(500);
            }
            if (FCRMaster.fcv.getOpenMenuNum() == 5) {
                if (FCUIConfig.getIn().checkUIClick("menuSettingExit", x, y)) {
                    FCRMaster.fcv.setEnterBu(FCUIConfig.getIn().getEnterBuByKey("menuSettingExit"));// 退出游戏
                } else if (FCUIConfig.getIn().checkUIClick("menuSettingBack", x, y)) {
                    FCRMaster.fcv.setEnterBu(FCUIConfig.getIn().getEnterBuByKey("menuSettingBack"));
// 设置返回主菜单
                } else if (FCUIConfig.getIn().checkUIClick("menuSettingMusic", x, y)) {
                    FCRMaster.fcv.setEnterBu(FCUIConfig.getIn().getEnterBuByKey("menuSettingMusic"));
// 设置音乐
                } else if (FCUIConfig.getIn().checkUIClick("menuSettingKeyReset", x, y)) {
                    FCRMaster.fcv.setEnterBu(FCUIConfig.getIn().getEnterBuByKey("menuSettingKeyReset"));
// 设置恢复默认
                } else if (FCUIConfig.getIn().checkUIClick("menuSettingSave", x, y)) {
                    FCRMaster.fcv.setEnterBu(FCUIConfig.getIn().getEnterBuByKey("menuSettingSave"));
                } else if (FCUIConfig.getIn().checkUIClick("menuSettingRead", x, y)) {
                    FCRMaster.fcv.setEnterBu(FCUIConfig.getIn().getEnterBuByKey("menuSettingRead"));
// 设置读档
                } else {
                    FCRMaster.fcv.setEnterBu(500);
                }
            } else if (FCRMaster.fcv.getOpenMenuNum() == 7) {

            }
        }
        if (FCRMaster.fcv.isShopVedingOpen()) {
            if (y > 277 * FCRMaster.fcv.getProportion() && y < 379 * FCRMaster.fcv.getProportion()) {// 1-3物品
                if (x > 604 * FCRMaster.fcv.getProportion() && x < 829 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingEnterNum(1);
                else if (x > 848 * FCRMaster.fcv.getProportion() && x < 1073 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingEnterNum(2);
                else if (x > 1096 * FCRMaster.fcv.getProportion() && x < 1317 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingEnterNum(3);
                else
                    FCRMaster.fcv.setShopVendingEnterNum(0);
            } else if (y > 401 * FCRMaster.fcv.getProportion() && y < 503 * FCRMaster.fcv.getProportion()) {// 4-6物品
                if (x > 604 * FCRMaster.fcv.getProportion() && x < 829 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingEnterNum(4);
                else if (x > 848 * FCRMaster.fcv.getProportion() && x < 1073 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingEnterNum(5);
                else if (x > 1096 * FCRMaster.fcv.getProportion() && x < 1317 * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setShopVendingEnterNum(6);
                else
                    FCRMaster.fcv.setShopVendingEnterNum(0);
            } else
                FCRMaster.fcv.setShopVendingEnterNum(0);
        }
        if (FCRMaster.fcv.isOpenPhonograph()) {// (int)(860*bili),(int)((610+32*i)*bili)
            if (x > 860 * FCRMaster.fcv.getProportion() && x < 1100 * FCRMaster.fcv.getProportion()) {
                FCRMaster.fcv.setPhonographEnterNum(-1);
                for (int i = 0; i < FCRMaster.fcv.getPhonographMusicName().size(); i++)
                    if (y > (578 + 32 * i) * FCRMaster.fcv.getProportion() && y < (610 + 32 * i) * FCRMaster.fcv.getProportion())
                        FCRMaster.fcv.setPhonographEnterNum(i);
            }
        }
        if (FCRMaster.fcv.getSayNpcSelectMenu().size() > 0) {
            FCRMaster.fcv.setSayMouseEnterSelectNum(-1);
            for (int i = 0; i < FCRMaster.fcv.getSayNpcSelectMenu().size(); i++)
                if (x > 1430 * FCRMaster.fcv.getProportion() && x < 1555 * FCRMaster.fcv.getProportion() && y > (753 + i * 44) * FCRMaster.fcv.getProportion()
                        && y < (793 + i * 44) * FCRMaster.fcv.getProportion())
                    FCRMaster.fcv.setSayMouseEnterSelectNum(i);
        }

        // 鼠标进入乘降菜单移动情况
        if (FCRMaster.fcv.isOpenUseTankMenu()) {
            if (x > FCRMaster.fcv.getTankMenuCoorX() + 38 * FCRMaster.fcv.getProportion() && x < FCRMaster.fcv.getTankMenuCoorX() + 166 * FCRMaster.fcv.getProportion()) {
                for (int i = 0; i < fcv.getCanUpTankTeamMembers().size() + 2; i++) {
                    if (y > FCRMaster.fcv.getTankMenuCoorY() + (17 + 43 * i) * FCRMaster.fcv.getProportion()
                            && y < FCRMaster.fcv.getTankMenuCoorY() + (57 + 43 * i) * FCRMaster.fcv.getProportion()) {
                        FCRMaster.fcv.setTankMenuMouseEnterX((int) (FCRMaster.fcv.getTankMenuCoorX() + 21 * FCRMaster.fcv.getProportion()));
                        FCRMaster.fcv.setTankMenuMouseEnterY((int) (FCRMaster.fcv.getTankMenuCoorY() + (25 + 43 * i) * FCRMaster.fcv.getProportion()));
                    } else {
                        FCRMaster.fcv.setTankMenuMouseEnterX(-1);
                        FCRMaster.fcv.setTankMenuMouseEnterY(-1);
                    }
                }
            } else {
                FCRMaster.fcv.setTankMenuMouseEnterX(-1);
                FCRMaster.fcv.setTankMenuMouseEnterY(-1);
            }
        }


        if (FCRMaster.fcv.getOpenMenuNum() == 1) {
            //TODO 要是菜单的战车页面就不给点底部栏的任意物品了，只能在这个范围内点击
            FCTank tank = null;
            if (fcv.getTanknameList().size() > 0) {
                tank = tankLib.getTankOfID(fcv.getTanknameList().get(fcv.getShowTankMenuTankIndex()),
                        fcv.getTankHostList().get(fcv.getShowTankMenuTankIndex()));
            }
            if (tank != null) {
                for (int i = 1; i < 11; i++) {
                    if (FCUIConfig.getIn().checkUIClick("tankMenuBagCell" + i, x, y)) {
                        FCItem item = itemLib.getItemOfID(tank.getKnapsack()[i - 1]);
                        if (item != null) {
                            FCRMaster.fcv.setShowingTankMenuDetail(item.getDetail());
                        }
                        break;
                    }
                }
                for (int i = 1; i < 9; i++) {
                    if (FCUIConfig.getIn().checkUIClick("tankMenuSellCase" + i, x, y)) {
                        FCItem item = itemLib.getItemOfID(tank.getChassisID());
                        if (item != null) {
                            if (i - 1 < item.getShellCaseNum()) {
                                FCItem item1 = itemLib.getItemOfID(item.getShellCaseType()[i - 1]);
                                if (item1 != null) {
                                    FCRMaster.fcv.setShowingTankMenuDetail(item1.getDetail());
                                }
                            }
                        }
                        break;
                    }
                }
                if (FCUIConfig.getIn().checkUIClick("tankMenuGun1", x, y)) {
                    FCItem item = itemLib.getItemOfID(tank.getGunID());
                    if (item != null) {
                        FCRMaster.fcv.setShowingTankMenuDetail(item.getDetail());
                    }
                } else if (FCUIConfig.getIn().checkUIClick("tankMenuGun2", x, y)) {
                    FCItem item = itemLib.getItemOfID(tank.getGun2ID());
                    if (item != null) {
                        FCRMaster.fcv.setShowingTankMenuDetail(item.getDetail());
                    }
                } else if (FCUIConfig.getIn().checkUIClick("tankMenuC", x, y)) {
                    FCItem item = itemLib.getItemOfID(tank.getCdeviceID());
                    if (item != null) {
                        FCRMaster.fcv.setShowingTankMenuDetail(item.getDetail());
                    }
                } else if (FCUIConfig.getIn().checkUIClick("tankMenuE", x, y)) {
                    FCItem item = itemLib.getItemOfID(tank.getEngineID());
                    if (item != null) {
                        FCRMaster.fcv.setShowingTankMenuDetail(item.getDetail());
                    }
                } else if (FCUIConfig.getIn().checkUIClick("tankMenuCA", x, y)) {
                    FCItem item = itemLib.getItemOfID(tank.getChassisID());
                    if (item != null) {
                        FCRMaster.fcv.setShowingTankMenuDetail(item.getDetail());
                    }
                } else if (FCUIConfig.getIn().checkUIClick("tankMenuSC", x, y)) {
                    FCItem item = itemLib.getItemOfID(tank.getRadarID());
                    if (item != null) {
                        FCRMaster.fcv.setShowingTankMenuDetail(item.getDetail());
                    }
                } else if (FCUIConfig.getIn().checkUIClick("tankMenuSE", x, y)) {
                    FCItem item = itemLib.getItemOfID(tank.getSEID());
                    if (item != null) {
                        FCRMaster.fcv.setShowingTankMenuDetail(item.getDetail());
                    }
                }
            }
        }
    }

    @Override
    public void listen_mouse_release_game(MouseEvent g) {
        if (g.getButton() != 1) {
            return;
        }
        int x = g.getX(), y = g.getY();
        if (FCRMaster.fcv.isOpenMenu() && FCRMaster.fcv.getOpenMenuNum() == 1 && FCRMaster.fcv.isMoveKnapsackItem()) {
            //TODO 要是菜单的战车页面就不给点底部栏的任意物品了，只能在这个范围内点击
            //TODO 如果是坦克装备界面
            FCTank tank = null;
            if (fcv.getTanknameList().size() > 0) {
                tank = tankLib.getTankOfID(fcv.getTanknameList().get(fcv.getShowTankMenuTankIndex()),
                        fcv.getTankHostList().get(fcv.getShowTankMenuTankIndex()));
            }
            if (tank != null && FCRMaster.fcv.getKnapsackItemName() != null && !FCRMaster.fcv.getKnapsackItemName().equals("null")) {
                FCItem moveItem = FCRMaster.itemLib.getItemOfID(FCRMaster.fcv.getKnapsackItemName());
                String itemtype = moveItem.getType();
                FCTank oldTank = fcv.getDragBagWitchTank();
                String oldItem = null;
                boolean canInsert = false;
                if (fcv.getKnapsackItemNum() >= 0) {//必须是从背包拖到这里的才做处理，不支持装备区移到装备区
                    if (tank.getType().equals("owner")) {
                        if (FCUIConfig.getIn().checkUIClick("tankMenuGun1", x, y)) {
                            if (itemtype.equals("gun1") || moveItem.isGun1HoleEnable()) {
                                canInsert = true;
                                oldItem = tank.getGunID();
                                tank.setGunID(gameSave.checkTankItem(FCRMaster.fcv.getKnapsackItemName()));
                            }
                        } else if (FCUIConfig.getIn().checkUIClick("tankMenuGun2", x, y)) {
                            if (itemtype.equals("gun2") || moveItem.isGun2HoleEnable()) {
                                canInsert = true;
                                oldItem = tank.getGun2ID();
                                tank.setGun2ID(gameSave.checkTankItem(FCRMaster.fcv.getKnapsackItemName()));
                            }
                        } else if (FCUIConfig.getIn().checkUIClick("tankMenuC", x, y)) {
                            if (itemtype.equals("Cdevice")) {
                                canInsert = true;
                                oldItem = tank.getCdeviceID();
                                tank.setCdeviceID(gameSave.checkTankItem(FCRMaster.fcv.getKnapsackItemName()));
                            }
                        } else if (FCUIConfig.getIn().checkUIClick("tankMenuE", x, y)) {
                            if (itemtype.equals("engine")) {
                                canInsert = true;
                                oldItem = tank.getEngineID();
                                tank.setEngineID(gameSave.checkTankItem(FCRMaster.fcv.getKnapsackItemName()));
                            }
                        } else if (FCUIConfig.getIn().checkUIClick("tankMenuCA", x, y)) {
                            if (itemtype.equals("chassis")) {
                                canInsert = true;
                                oldItem = tank.getChassisID();
                                tank.setChassisID(gameSave.checkTankItem(FCRMaster.fcv.getKnapsackItemName()));
                            }
                        } else if (FCUIConfig.getIn().checkUIClick("tankMenuSC", x, y)) {
                            if (itemtype.equals("radar")) {
                                canInsert = true;
                                oldItem = tank.getRadarID();
                                tank.setRadarID(gameSave.checkTankItem(FCRMaster.fcv.getKnapsackItemName()));
                            }
                        } else if (FCUIConfig.getIn().checkUIClick("tankMenuSE", x, y)) {
                            if (itemtype.equals("se")) {
                                canInsert = true;
                                oldItem = tank.getSEID();
                                tank.setSEID(gameSave.checkTankItem(FCRMaster.fcv.getKnapsackItemName()));
                            }
                        }
                    }
                    //TODO 没拖到背包就检查下是不是拖到了弹仓区,弹仓只能拖上去，不能丢弃
                    if (!canInsert && itemtype.equals("shell") && tank.getChassisID() != null && !tank.getChassisID().equals("null")) {
                        FCItem dipan = itemLib.getItemOfID(tank.getChassisID());
                        for (int i = 1; i < dipan.getShellCaseNum() + 1; i++) {
                            if (FCUIConfig.getIn().checkUIClick("tankMenuSellCase" + i, x, y)) {
                                String oldItemName = dipan.getShellCaseType()[i - 1];
                                if (oldItemName == null || oldItemName.equals("null") || oldItemName.equals(FCRMaster.fcv.getKnapsackItemName())) {
                                    dipan.getShellCaseType()[i - 1] = FCRMaster.fcv.getKnapsackItemName();
                                    FCItemForTankHelper.addShellCount(dipan, i - 1, 1);
                                    canInsert = true;
                                    oldItem = "null";
                                }
                                break;
                            }
                        }
                    }
                }
                if (canInsert) {
                    oldTank.insertItemToKnapsack(fcv.getKnapsackItemNum(), oldItem);
                    tank.reInitShuxing();
                    oldTank.reInitShuxing();
                } else {
                    //TODO 那就是拖到了坦克背包了哦
                    for (int i = 1; i < 11; i++) {
                        if (FCUIConfig.getIn().checkUIClick("tankMenuBagCell" + i, x, y)) {
                            if (fcv.getKnapsackItemNum() >= 0) {
                                //从背包到背包的
                                oldItem = tank.getKnapsack()[i - 1];
                                tank.insertItemToKnapsack(i - 1, FCRMaster.fcv.getKnapsackItemName());
                                replaceOrDelKnapsack(oldItem);
                                tank.reInitShuxing();
                                oldTank.reInitShuxing();

                            } else {
                                //从装备区到背包的，要判断是否能互换新的物品，不能就不给放
                                oldItem = tank.getKnapsack()[i - 1];
                                if (oldItem == null || oldItem.equals("null")) {
                                    tank.insertItemToKnapsack(i - 1, FCRMaster.fcv.getKnapsackItemName());
                                    if (FCRMaster.fcv.getTakeOffArmorType() == 0) {
                                        oldTank.setGunID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 1) {
                                        oldTank.setGun2ID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 2) {
                                        oldTank.setCdeviceID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 3) {
                                        oldTank.setEngineID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 4) {
                                        oldTank.setChassisID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 5) {
                                        oldTank.setRadarID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 6) {
                                        oldTank.setSEID(oldItem);
                                    }
                                } else {
                                    String oldItemType = FCRMaster.itemLib.getItemOfID(oldItem).getType();
                                    if (FCRMaster.fcv.getTakeOffArmorType() == 0 && oldItemType.equals("gun1")) {
                                        tank.insertItemToKnapsack(i - 1, FCRMaster.fcv.getKnapsackItemName());
                                        oldTank.setGunID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 1 && oldItemType.equals("gun2")) {
                                        tank.insertItemToKnapsack(i - 1, FCRMaster.fcv.getKnapsackItemName());
                                        oldTank.setGun2ID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 2 && oldItemType.equals("Cdevice")) {
                                        tank.insertItemToKnapsack(i - 1, FCRMaster.fcv.getKnapsackItemName());
                                        oldTank.setCdeviceID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 3 && oldItemType.equals("engine")) {
                                        tank.insertItemToKnapsack(i - 1, FCRMaster.fcv.getKnapsackItemName());
                                        oldTank.setEngineID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 4 && oldItemType.equals("chassis")) {
                                        tank.insertItemToKnapsack(i - 1, FCRMaster.fcv.getKnapsackItemName());
                                        oldTank.setChassisID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 5 && oldItemType.equals("radar")) {
                                        tank.insertItemToKnapsack(i - 1, FCRMaster.fcv.getKnapsackItemName());
                                        oldTank.setRadarID(oldItem);
                                    } else if (FCRMaster.fcv.getTakeOffArmorType() == 6 && oldItemType.equals("se")) {
                                        tank.insertItemToKnapsack(i - 1, FCRMaster.fcv.getKnapsackItemName());
                                        oldTank.setSEID(oldItem);
                                    }
                                }
                                tank.reInitShuxing();
                                oldTank.reInitShuxing();
                            }
                            break;
                        }
                    }
                }
            }
            FCRMaster.fcv.setTakeOffArmorType(-1);
            FCRMaster.fcv.setKnapsackItemNum(-1);
            FCRMaster.fcv.setKnapsackItemName("null");
            FCRMaster.fcv.setDragBagWitchTank(null);
            FCRMaster.fcv.setMoveKnapsackItem(false);
            if (FCRMaster.fcv.isSever()) {
                FCRSocketServer.getIn().syncOthterPlayerTankStateAndItems();
            } else if (FCRMaster.fcv.isClient()) {
                FCRSocketClient.getIn().syncOthterPlayerTankStateAndItems();
            }
            return;
        }

        FCPlayerInfo fcPlayerInfo = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getShowWhosBagItem());
        if (fcPlayerInfo != null) {
            // 丢弃物品-背包
            if (FCRMaster.fcv.getBattlePlayerOneSelectMonster() < 0 && FCRMaster.fcv.getCaseSelectNum() < 0 && FCRMaster.fcv.isMoveKnapsackItem()) {
                //从背包拖出来丢弃
                if (!FCRMaster.fcv.isOpenMenu() && FCRMaster.fcv.getKnapsackItemNum() >= 0 && (y < 926 * FCRMaster.fcv.getProportion()
                        || x < 633 * FCRMaster.fcv.getProportion() || x > 1287 * FCRMaster.fcv.getProportion())) {
                    FCPlayerInfo oldman = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getKnapsackItemWho());
                    if (FCRMaster.fcv.getKnapsackItemType() == 1) {
                        //丢的是人类背包的
                        FCItem dropItem = itemLib.getItemOfID(oldman.getKnapsack()[FCRMaster.fcv.getKnapsackItemNum()]);
                        fcv.getMessage().add("丢弃了物品-" + dropItem.getChName());
                        fcv.showMessage();
                        oldman.subItemToKnapsackOfNum(FCRMaster.fcv.getKnapsackItemNum());
                    } else if (FCRMaster.fcv.getKnapsackItemType() == 2) {
                        FCTank tank = tankLib.getTankOfID(oldman.getPlayertank1(), oldman.getPlayertankHostId());
                        if (tank != null) {
                            FCItem dropItem = itemLib.getItemOfID(tank.getKnapsack()[FCRMaster.fcv.getKnapsackItemNum()]);
                            fcv.getMessage().add("丢弃了物品-" + dropItem.getChName());
                            fcv.showMessage();
                            tank.insertItemToKnapsack(FCRMaster.fcv.getKnapsackItemNum(), "null");
                            gameSave.delTankItemClone(FCRMaster.fcv.getKnapsackItemName());
                            tank.reInitShuxing();
                            //丢的是坦克道具，所以就删除备份对象
                        }
                    }
                    FCRMaster.fcv.setKnapsackItemNum(-1);
                    FCRMaster.fcv.setKnapsackItemName("null");
                    FCRMaster.fcv.setMoveKnapsackItem(false);
                } else {
                    // 背包内移动
                    if (y > (int) (1016 * FCRMaster.fcv.getProportion()) && y < (int) (1066 * FCRMaster.fcv.getProportion())) {
                        FCItem item = itemLib.getItemOfID(fcv.getKnapsackItemName());
                        if (item != null && "tank".equals(item.getCatalog())) {
                            fcv.getMessage().add("很抱歉，战车道具要坦克背包!");
                            fcv.showMessage();
                            FCRMaster.fcv.setKnapsackItemNum(-1);
                            FCRMaster.fcv.setKnapsackItemName("null");
                            FCRMaster.fcv.setMoveKnapsackItem(false);
                            return;
                        }
                        for (int i = 0; i < 10; i++) {
                            if (x > (int) ((647 + i * 64) * FCRMaster.fcv.getProportion())
                                    && x < (int) ((697 + i * 64) * FCRMaster.fcv.getProportion())) {
                                if (FCRMaster.fcv.getKnapsackItemNum() >= 0) {
                                    //step1 把新物品放在这个格子上，格子删除这个
                                    //step2 如果这个格子有物品，则放回之前的格子上
                                    String oldItem = fcPlayerInfo.getKnapsackItemIDOfNum(i);
                                    fcPlayerInfo.insertItemToKnapsack(i, FCRMaster.fcv.getKnapsackItemName());
                                    replaceOrDelKnapsack(oldItem);
                                } else {
                                    //把装备卸下来，要判断下能不能放，如果这个格子有物品了，不能放
                                    String oldItem = fcPlayerInfo.getKnapsackItemIDOfNum(i);
                                    if (oldItem == null || oldItem.equals("null")) {
                                        //空格子才能把装备卸下来
                                        fcPlayerInfo.insertItemToKnapsack(i, FCRMaster.fcv.getKnapsackItemName());
                                        FCPlayerInfo oldman = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getKnapsackItemWho());
                                        if (FCRMaster.fcv.getTakeOffArmorType() == 0) {
                                            oldman.setArm("null");
                                        } else if (FCRMaster.fcv.getTakeOffArmorType() == 1) {
                                            oldman.setHat("null");
                                        } else if (FCRMaster.fcv.getTakeOffArmorType() == 2) {
                                            oldman.setJacket("null");
                                        } else if (FCRMaster.fcv.getTakeOffArmorType() == 3) {
                                            oldman.setPants("null");
                                        } else if (FCRMaster.fcv.getTakeOffArmorType() == 4) {
                                            oldman.setShoes("null");
                                        } else if (FCRMaster.fcv.getTakeOffArmorType() == 5) {
                                            oldman.setGlove("null");
                                        }
                                        if (FCRMaster.fcv.getTakeOffArmorType() >= 0) {
                                            syncEquipToNet(oldman);
                                        }
                                    }
                                    FCRMaster.fcv.setTakeOffArmorType(-1);
                                    FCRMaster.fcv.setKnapsackItemNum(-1);
                                    FCRMaster.fcv.setKnapsackItemName("null");
                                    FCRMaster.fcv.setMoveKnapsackItem(false);
                                }
                                break;
                            }
                        }
                    } else if (y > (int) (930 * FCRMaster.fcv.getProportion()) && y < (int) (984 * FCRMaster.fcv.getProportion())) {
                        FCTank tank = tankLib.getTankOfID(fcPlayerInfo.getPlayertank1(), fcPlayerInfo.getPlayertankHostId());
                        if (tank != null) {
                            for (int i = 0; i < 10; i++)
                                if (x > (int) ((647 + i * 64) * FCRMaster.fcv.getProportion())
                                        && x < (int) ((697 + i * 64) * FCRMaster.fcv.getProportion())) {
                                    if (FCRMaster.fcv.getKnapsackItemNum() >= 0) {
                                        String oldItem = tank.getKnapsackItemIDOfNum(i);
                                        FCItem item = itemLib.getItemOfID(oldItem);
                                        if (FCRMaster.fcv.getKnapsackItemType() == 1 && item != null && "tank".equals(item.getCatalog())) {
                                            fcv.getMessage().add("很抱歉，坦克道具不能交换放到人类背包!");
                                            fcv.showMessage();
                                            FCRMaster.fcv.setKnapsackItemNum(-1);
                                            FCRMaster.fcv.setKnapsackItemName("null");
                                            FCRMaster.fcv.setMoveKnapsackItem(false);
                                            return;
                                        }
                                        tank.insertItemToKnapsack(i, FCRMaster.fcv.getKnapsackItemName());
                                        tank.reInitShuxing();
                                        replaceOrDelKnapsack(oldItem);
                                    } else {
                                        String oldItem = tank.getKnapsackItemIDOfNum(i);
                                        if (oldItem == null || oldItem.equals("null")) {
                                            tank.insertItemToKnapsack(i, FCRMaster.fcv.getKnapsackItemName());
                                            tank.reInitShuxing();
                                            //卸载人类装备
                                            if (FCRMaster.fcv.getKnapsackItemType() == 1) {
                                                //空格子才能把装备卸下来
                                                FCPlayerInfo oldman = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getKnapsackItemWho());
                                                if (FCRMaster.fcv.getTakeOffArmorType() == 0) {
                                                    oldman.setArm("null");
                                                } else if (FCRMaster.fcv.getTakeOffArmorType() == 1) {
                                                    oldman.setHat("null");
                                                } else if (FCRMaster.fcv.getTakeOffArmorType() == 2) {
                                                    oldman.setJacket("null");
                                                } else if (FCRMaster.fcv.getTakeOffArmorType() == 3) {
                                                    oldman.setPants("null");
                                                } else if (FCRMaster.fcv.getTakeOffArmorType() == 4) {
                                                    oldman.setShoes("null");
                                                } else if (FCRMaster.fcv.getTakeOffArmorType() == 5) {
                                                    oldman.setGlove("null");
                                                }
                                                if (FCRMaster.fcv.getTakeOffArmorType() >= 0) {
                                                    syncEquipToNet(oldman);
                                                }
                                            }
                                        }
                                        FCRMaster.fcv.setTakeOffArmorType(-1);
                                        FCRMaster.fcv.setKnapsackItemNum(-1);
                                        FCRMaster.fcv.setKnapsackItemName("null");
                                        FCRMaster.fcv.setMoveKnapsackItem(false);
                                    }
                                    break;
                                }
                        }
                    }
                }
            }

            // 装备装备,禁止卸载装备的时候把装备放到其他角色行，必须先放回背包，再从背包装备到角色上
            if (FCRMaster.fcv.isOpenMenu() && FCRMaster.fcv.isMoveKnapsackItem() && FCRMaster.fcv.getKnapsackItemName() != null
                    && !FCRMaster.fcv.getKnapsackItemName().equals("null") && FCRMaster.fcv.getTakeOffArmorType() == -1) {
                if (FCRMaster.fcv.getOpenMenuNum() == 0) {
                    //TODO 如果是人类装备界面
                    FCItem moveItem = FCRMaster.itemLib.getItemOfID(FCRMaster.fcv.getKnapsackItemName());
                    String itemtype = moveItem.getType();
                    int offsetY = (int) (50 * fcv.getProportion());
                    for (int i = 0; i < FCMutilPlayCache.getTeamMembers().size() + 1; i++) {
                        FCPlayerInfo p = null;
                        if (i == 0) {
                            p = player1;
                        } else {
                            FCRPlayerLink link = FCMutilPlayCache.getTeamMembers().get(i - 1);
                            if (link.curPlayerHostUID.equals(gameSave.HOST_UID)) {
                                p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, link.curPlayerName);
                            }
                        }
                        if (p == null) {
                            continue;
                        }

                        if (x > 539 * FCRMaster.fcv.getProportion() && x < 581 * FCRMaster.fcv.getProportion() && y > offsetY + 252.5 * FCRMaster.fcv.getProportion()
                                && y < offsetY + 294.5 * FCRMaster.fcv.getProportion()) // 装备武器
                        {
                            if (itemtype.equals("arm")) {
                                if (!moveItem.getEnableOccupation().contains(p.getOccupation())) {
                                    fcv.getMessage().add("职业限制无法装备!");
                                    fcv.showMessage();
                                } else {
                                    String oldItem = p.getArm();
                                    p.setArm(FCRMaster.fcv.getKnapsackItemName());
                                    replaceOrDelKnapsack(oldItem);
                                    syncEquipToNet(p);
                                }
                            }
                            break;
                        }
                        if (x > 505 * FCRMaster.fcv.getProportion() && x < 539 * FCRMaster.fcv.getProportion() && y > offsetY + 218.5 * FCRMaster.fcv.getProportion()
                                && y < offsetY + 252.5 * FCRMaster.fcv.getProportion()) // 装备帽子
                        {
                            if (itemtype.equals("hat")) {
                                if (!moveItem.getEnableOccupation().contains(p.getOccupation())) {
                                    fcv.getMessage().add("职业限制无法装备!");
                                    fcv.showMessage();
                                } else {
                                    String oldItem = p.getHat();
                                    p.setHat(FCRMaster.fcv.getKnapsackItemName());
                                    replaceOrDelKnapsack(oldItem);
                                    syncEquipToNet(p);
                                }
                            }
                            break;
                        }
                        if (x > 581 * FCRMaster.fcv.getProportion() && x < 615 * FCRMaster.fcv.getProportion() && y > offsetY + 218.5 * FCRMaster.fcv.getProportion()
                                && y < offsetY + 252.5 * FCRMaster.fcv.getProportion()) // 装备上衣
                        {
                            if (itemtype.equals("jacket")) {
                                if (!moveItem.getEnableOccupation().contains(p.getOccupation())) {
                                    fcv.getMessage().add("职业限制无法装备!");
                                    fcv.showMessage();
                                } else {
                                    String oldItem = p.getJacket();
                                    p.setJacket(FCRMaster.fcv.getKnapsackItemName());
                                    replaceOrDelKnapsack(oldItem);
                                    syncEquipToNet(p);
                                }
                            }
                            break;
                        }
                        if (x > 505 * FCRMaster.fcv.getProportion() && x < 539 * FCRMaster.fcv.getProportion() && y > offsetY + 294.5 * FCRMaster.fcv.getProportion()
                                && y < offsetY + 328.5 * FCRMaster.fcv.getProportion()) // 装备防弹衣
                        {
                            if (itemtype.equals("pants")) {
                                if (!moveItem.getEnableOccupation().contains(p.getOccupation())) {
                                    fcv.getMessage().add("职业限制无法装备!");
                                    fcv.showMessage();
                                } else {
                                    String oldItem = p.getPants();
                                    p.setPants(gameSave.checkOtherItem(FCRMaster.fcv.getKnapsackItemName()));
                                    replaceOrDelKnapsack(oldItem);
                                    syncEquipToNet(p);
                                }
                            }
                            break;
                        }
                        if (x > 458 * FCRMaster.fcv.getProportion() && x < 502 * FCRMaster.fcv.getProportion() && y > offsetY + 294.5 * FCRMaster.fcv.getProportion()
                                && y < offsetY + 328.5 * FCRMaster.fcv.getProportion()) // 装备手套
                        {
                            if (itemtype.equals("glove")) {
                                if (!moveItem.getEnableOccupation().contains(p.getOccupation())) {
                                    fcv.getMessage().add("职业限制无法装备!");
                                    fcv.showMessage();
                                } else {
                                    String oldItem = p.getGlove();
                                    p.setGlove(FCRMaster.fcv.getKnapsackItemName());
                                    replaceOrDelKnapsack(oldItem);
                                    syncEquipToNet(p);
                                }
                            }
                            break;
                        }
                        if (x > 581 * FCRMaster.fcv.getProportion() && x < 615 * FCRMaster.fcv.getProportion() && y > offsetY + 294.5 * FCRMaster.fcv.getProportion()
                                && y < offsetY + 328.5 * FCRMaster.fcv.getProportion()) // 装备鞋子
                        {
                            if (itemtype.equals("shoes")) {
                                if (!moveItem.getEnableOccupation().contains(p.getOccupation())) {
                                    fcv.getMessage().add("职业限制无法装备!");
                                    fcv.showMessage();
                                } else {
                                    String oldItem = p.getShoes();
                                    p.setShoes(FCRMaster.fcv.getKnapsackItemName());
                                    replaceOrDelKnapsack(oldItem);
                                    syncEquipToNet(p);
                                }
                            }
                            break;
                        }

                        offsetY += (int) (145 * fcv.getProportion());
                    }
                }
            }

            // 箱子拿物品去背包
            if (FCRMaster.fcv.isOpenCase()) {
                if (FCRMaster.fcv.getCaseSelectNum() > -1) {
                    CaseEvent caseE = (CaseEvent) FCRMaster.fcv.getPlayingEvent();
                    String itemId = caseE.getCaseitem()[FCRMaster.fcv.getCaseSelectNum()];
                    if (y > (int) (1016 * FCRMaster.fcv.getProportion()) && y < (int) (1066 * FCRMaster.fcv.getProportion())) {
                        FCItem item = itemLib.getItemOfID(itemId);
                        if ("tank".equals(item.getCatalog())) {
                            FCRMaster.fcv.setCaseSelectNum(-1);
                            fcv.getMessage().add("很抱歉，战车道具要坦克背包!");
                            fcv.showMessage();
                            return;
                        }
                        for (int i = 0; i < 10; i++) {
                            if (x > (int) ((647 + i * 64) * FCRMaster.fcv.getProportion())
                                    && x < (int) ((697 + i * 64) * FCRMaster.fcv.getProportion())) {
                                if (fcPlayerInfo.itemMoveOfCase(i, itemId)) {
                                    caseE.deleteCaseItemOfNum(FCRMaster.fcv.getCaseSelectNum());
                                    FCRMaster.gameSave.setCaseUpdateInfo(FCRMaster.fcv.getPlayingEvent().getName(), caseE.getCaseitem());
                                }
                                break;
                            }
                        }
                    } else if (y > (int) (930 * FCRMaster.fcv.getProportion()) && y < (int) (984 * FCRMaster.fcv.getProportion())) {
                        FCTank tank = tankLib.getTankOfID(fcPlayerInfo.getPlayertank1(), fcPlayerInfo.getPlayertankHostId());
                        if (tank != null) {
                            for (int i = 0; i < 10; i++) {
                                if (x > (int) ((647 + i * 64) * FCRMaster.fcv.getProportion())
                                        && x < (int) ((697 + i * 64) * FCRMaster.fcv.getProportion())) {
                                    if (tank.itemMoveOfCase(i, itemId)) {
                                        tank.reInitShuxing();
                                        caseE.deleteCaseItemOfNum(FCRMaster.fcv.getCaseSelectNum());
                                        FCRMaster.gameSave.setCaseUpdateInfo(FCRMaster.fcv.getPlayingEvent().getName(), caseE.getCaseitem());

                                    }
                                    break;
                                }
                            }
                        }
                    }
                    FCRMaster.fcv.setCaseSelectNum(-1);
                }
            }


            //TODO 一放手，就全部恢复了
            if (FCRMaster.fcv.isMoveKnapsackItem()) {
                FCRMaster.fcv.setKnapsackItemNum(-1);
                FCRMaster.fcv.setKnapsackItemName("null");
                FCRMaster.fcv.setMoveKnapsackItem(false);
            }
        }
    }


    private void replaceOrDelKnapsack(String oldItem) {
        if (FCRMaster.fcv.getKnapsackItemType() == 1) {
            FCPlayerInfo oldman = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getKnapsackItemWho());
            //人类背包
            oldman.insertItemToKnapsack(FCRMaster.fcv.getKnapsackItemNum(), oldItem);
        } else {
            //坦克背包
            FCTank tank = fcv.getDragBagWitchTank();
            if (tank != null) {
                tank.insertItemToKnapsack(FCRMaster.fcv.getKnapsackItemNum(), oldItem);
                tank.reInitShuxing();
            }
        }
        FCRMaster.fcv.setKnapsackItemNum(-1);
        FCRMaster.fcv.setKnapsackItemName("null");
        FCRMaster.fcv.setMoveKnapsackItem(false);
    }

    @Override
    public void listen_mouse_press_game(MouseEvent g) {
        int x = g.getX(), y = g.getY();
        if (g.getButton() == 1) {
            //TODO 长按左键
            if (FCRMaster.fcv.isOpenMenu() && FCRMaster.fcv.getOpenMenuNum() == 1) {
                //TODO 要是菜单的战车页面就不给点底部栏的任意物品了，只能在这个范围内点击
                FCTank tank = null;
                if (fcv.getTanknameList().size() > 0) {
                    tank = tankLib.getTankOfID(fcv.getTanknameList().get(fcv.getShowTankMenuTankIndex()),
                            fcv.getTankHostList().get(fcv.getShowTankMenuTankIndex()));
                }
                //出租的车不能拖动装备
                if (tank != null && tank.getType().equals("owner")) {
                    for (int i = 1; i < 11; i++) {
                        if (FCUIConfig.getIn().checkUIClick("tankMenuBagCell" + i, x, y)) {
                            FCRMaster.fcv.setKnapsackItemNum(i - 1);
                            FCRMaster.fcv.setKnapsackItemType(2);
                            FCRMaster.fcv.setKnapsackItemName(tank.getKnapsack()[i - 1]);
                            FCRMaster.fcv.setDragBagWitchTank(tank);
                            FCRMaster.fcv.setMoveKnapsackItem(true);
                            return;
                        }
                    }
                    //TODO 拖装备
                    boolean isDragArmor = false;
                    if (FCUIConfig.getIn().checkUIClick("tankMenuGun1", x, y)) {
                        FCRMaster.fcv.setKnapsackItemName(tank.getGunID());
                        isDragArmor = true;
                        FCRMaster.fcv.setTakeOffArmorType(0);
                    } else if (FCUIConfig.getIn().checkUIClick("tankMenuGun2", x, y)) {
                        FCRMaster.fcv.setKnapsackItemName(tank.getGun2ID());
                        isDragArmor = true;
                        FCRMaster.fcv.setTakeOffArmorType(1);
                    } else if (FCUIConfig.getIn().checkUIClick("tankMenuC", x, y)) {
                        FCRMaster.fcv.setKnapsackItemName(tank.getCdeviceID());
                        isDragArmor = true;
                        FCRMaster.fcv.setTakeOffArmorType(2);
                    } else if (FCUIConfig.getIn().checkUIClick("tankMenuE", x, y)) {
                        FCRMaster.fcv.setKnapsackItemName(tank.getEngineID());
                        isDragArmor = true;
                        FCRMaster.fcv.setTakeOffArmorType(3);
                    } else if (FCUIConfig.getIn().checkUIClick("tankMenuCA", x, y)) {
                        FCRMaster.fcv.setKnapsackItemName(tank.getChassisID());
                        isDragArmor = true;
                        FCRMaster.fcv.setTakeOffArmorType(4);
                    } else if (FCUIConfig.getIn().checkUIClick("tankMenuSC", x, y)) {
                        FCRMaster.fcv.setKnapsackItemName(tank.getRadarID());
                        isDragArmor = true;
                        FCRMaster.fcv.setTakeOffArmorType(5);
                    } else if (FCUIConfig.getIn().checkUIClick("tankMenuSE", x, y)) {
                        FCRMaster.fcv.setKnapsackItemName(tank.getSEID());
                        isDragArmor = true;
                        FCRMaster.fcv.setTakeOffArmorType(6);
                    }
                    if (isDragArmor) {
                        FCRMaster.fcv.setKnapsackItemNum(-1);
                        FCRMaster.fcv.setKnapsackItemType(2);
                        FCRMaster.fcv.setDragBagWitchTank(tank);
                        FCRMaster.fcv.setMoveKnapsackItem(true);
                    }
                }
                return;
            }
            FCPlayerInfo fcPlayerInfo = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, fcv.getShowWhosBagItem());
            // 人物背包
            if (y > (int) (1016 * FCRMaster.fcv.getProportion()) && y < (int) (1066 * FCRMaster.fcv.getProportion()) && FCRMaster.fcv.getCaseSelectNum() < 0) {
                for (int i = 0; i < 10; i++)
                    if (x > (int) ((647 + i * 64) * FCRMaster.fcv.getProportion()) && x < (int) ((697 + i * 64) * FCRMaster.fcv.getProportion())) {
                        String pIName = fcPlayerInfo.getKnapsack()[i];
                        if (pIName != null && !pIName.equals("null")) {
                            FCRMaster.fcv.setKnapsackItemNum(i);
                            FCRMaster.fcv.setKnapsackItemType(1);
                            FCRMaster.fcv.setKnapsackItemName(fcPlayerInfo.getKnapsackItemIDOfNum(i));
                            FCRMaster.fcv.setKnapsackItemWho(fcv.getShowWhosBagItem());
                            FCRMaster.fcv.setMoveKnapsackItem(true);
                        }
                    }
            } else if (y > (int) (930 * FCRMaster.fcv.getProportion()) && y < (int) (984 * FCRMaster.fcv.getProportion())) {
                //坦克背包
                FCTank tank = tankLib.getTankOfID(fcPlayerInfo.getPlayertank1(), fcPlayerInfo.getPlayertankHostId());
                if (tank != null) {
                    for (int i = 0; i < 10; i++)
                        if (x > (int) ((647 + i * 64) * FCRMaster.fcv.getProportion()) && x < (int) ((697 + i * 64) * FCRMaster.fcv.getProportion())) {
                            String tankIName = tank.getKnapsack()[i];
                            if (tankIName != null && !tankIName.equals("null")) {
                                if (tankIName.contains(FCRConstants.QianZhuName) || tankIName.contains(FCRConstants.BridShitName)) {
                                    fcv.getMessage().add("该物品只能清洗店去掉!");
                                    fcv.showMessage();
                                } else {
                                    FCRMaster.fcv.setKnapsackItemNum(i);
                                    FCRMaster.fcv.setKnapsackItemType(2);
                                    FCRMaster.fcv.setDragBagWitchTank(tank);
                                    FCRMaster.fcv.setKnapsackItemName(tank.getKnapsackItemIDOfNum(i));
                                    FCRMaster.fcv.setKnapsackItemWho(fcv.getShowWhosBagItem());
                                    FCRMaster.fcv.setMoveKnapsackItem(true);
                                }
                            }
                        }
                }
            }
            // 箱子物品移动
            if (y > 536.5 * FCRMaster.fcv.getProportion() && y < 586.5 * FCRMaster.fcv.getProportion() && FCRMaster.fcv.isOpenCase()) {
                for (int i = 0; i < 4; i++) {
                    if (x > (817.5 + 79 * i) * FCRMaster.fcv.getProportion() && x < (867.5 + 79 * i) * FCRMaster.fcv.getProportion()) {
                        FCRMaster.fcv.setCaseSelectNum(i);
                        break;
                    }
                }
            }
            // 卸下装备
            if (FCRMaster.fcv.isOpenMenu() && FCRMaster.fcv.getOpenMenuNum() == 0) {
                FCRMaster.fcv.setTakeOffArmorType(-1);
                int offsetY = (int) (50 * fcv.getProportion());
                for (int i = 0; i < FCMutilPlayCache.getTeamMembers().size() + 1; i++) {
                    FCPlayerInfo p = null;
                    if (i == 0) {
                        p = player1;
                    } else {
                        FCRPlayerLink link = FCMutilPlayCache.getTeamMembers().get(i - 1);
                        if (link.curPlayerHostUID.equals(gameSave.HOST_UID)) {
                            p = FCMutilPlayCache.findPlayerByName(gameSave.HOST_UID, link.curPlayerName);
                        }
                    }
                    if (p == null) {
                        continue;
                    }
                    if (x > 539 * FCRMaster.fcv.getProportion() && x < 581 * FCRMaster.fcv.getProportion() && y > offsetY + 252.5 * FCRMaster.fcv.getProportion()
                            && y < offsetY + 294.5 * FCRMaster.fcv.getProportion()) {
                        takeOffArmor(p, p.getArm(), 0);
                        break;
                    } else if (x > 505 * FCRMaster.fcv.getProportion() && x < 539 * FCRMaster.fcv.getProportion() && y > offsetY + 218.5 * FCRMaster.fcv.getProportion()
                            && y < offsetY + 252.5 * FCRMaster.fcv.getProportion()) {
                        takeOffArmor(p, p.getHat(), 1);
                        break;
                    } else if (x > 581 * FCRMaster.fcv.getProportion() && x < 615 * FCRMaster.fcv.getProportion() && y > offsetY + 218.5 * FCRMaster.fcv.getProportion()
                            && y < offsetY + 252.5 * FCRMaster.fcv.getProportion()) {
                        takeOffArmor(p, p.getJacket(), 2);
                        break;
                    } else if (x > 458 * FCRMaster.fcv.getProportion() && x < 502 * FCRMaster.fcv.getProportion() && y > offsetY + 294.5 * FCRMaster.fcv.getProportion()
                            && y < offsetY + 628.5 * FCRMaster.fcv.getProportion()) {
                        takeOffArmor(p, p.getGlove(), 5);
                        break;
                    } else if (x > 505 * FCRMaster.fcv.getProportion() && x < 539 * FCRMaster.fcv.getProportion() && y > offsetY + 294.5 * FCRMaster.fcv.getProportion()
                            && y < offsetY + 628.5 * FCRMaster.fcv.getProportion()) {
                        takeOffArmor(p, p.getPants(), 3);
                        break;
                    } else if (x > 581 * FCRMaster.fcv.getProportion() && x < 615 * FCRMaster.fcv.getProportion() && y > offsetY + 294.5 * FCRMaster.fcv.getProportion()
                            && y < offsetY + 328.5 * FCRMaster.fcv.getProportion()) {
                        takeOffArmor(p, p.getShoes(), 4);
                        break;
                    }
                    offsetY += (int) (145 * fcv.getProportion());
                }
            }
        }
    }

    @Override
    public void listen_key_press_game(String e) {

    }

    private boolean takeOffArmor(FCPlayerInfo p, String itemName, int type) {
        if (itemName != null && !itemName.equals("null")) {
            FCRMaster.fcv.setTakeOffArmorType(type);
            FCRMaster.fcv.setKnapsackItemNum(-1);
            FCRMaster.fcv.setKnapsackItemType(1);
            FCRMaster.fcv.setKnapsackItemName(itemName);
            FCRMaster.fcv.setKnapsackItemWho(p.getName());
            FCRMaster.fcv.setMoveKnapsackItem(true);
            return true;
        }
        return false;
    }

    private void syncEquipToNet(FCPlayerInfo p) {
        if (fcv.isSever()) {
            FCRSocketServer.getIn().syncPlayerEquip(p);
        } else if (fcv.isClient()) {
            FCRSocketClient.getIn().syncPlayerEquip(p);
        }
    }
}
